import { Prisma } from '@prisma/client';
import { Transform } from 'class-transformer';
import { IsDefined } from 'class-validator';
import { BaseQueryDto } from './base.dto';

export class BillQueryDto extends BaseQueryDto<
  Prisma.BillWhereUniqueInput & {
    realname?: string;
    mobile?: string;
    startTime?: string;
    endTime?: string;
  }
> {}

export class BillRefundDto extends BaseQueryDto<
  Prisma.BillWhereUniqueInput & {
    serialNo?: string;
    billNo?: string;
    refundCoreNo?: string;
    startTime?: string;
    endTime?: string;
    rcvName?: string;
  }
> {}

export class BillListDto extends BaseQueryDto<Prisma.BillWhereUniqueInput> {}

export class BillCheckDto {
  @IsDefined({ message: 'ID必填' })
  @Transform(({ value }) => Number(value))
  id: number;
}

export class BillWithdrawDto {
  @IsDefined({ message: 'ID必填' })
  @Transform(({ value }) => Number(value))
  id: number;
}

export class BillWithdrawBatchDto {
  @IsDefined({ message: '开始时间' })
  startTime: string;

  @IsDefined({ message: '结束时间' })
  endTime: string;
}

export class BillRejectDto {
  @IsDefined({ message: 'ID必填' })
  @Transform(({ value }) => Number(value))
  id: number;

  @IsDefined({ message: '驳回理由' })
  remark: string;
}

export class BillInfoDto {
  @IsDefined({ message: 'ID必填' })
  @Transform(({ value }) => Number(value))
  id: number;
}

export class BillRollbackDto {
  @IsDefined({ message: 'ID必填' })
  @Transform(({ value }) => Number(value))
  id: number;

  @IsDefined({ message: '回滚理由' })
  remark: string;
}
